Views: Removed strongly typed View Settings#2066
Conversation
There was a problem hiding this comment.
Pull request overview
This PR decouples per-view settings typing from the generated REST schema by moving frontend-owned view settings types into a dedicated module, reducing coupling to backend schema/codegen changes and stabilizing the view save/create contract.
Changes:
- Introduce
shared/src/api/viewSettings.tsto own view settings and column type shapes on the frontend. - Repoint view-settings consumers across pages/shared utilities to import settings types from
@shared/api/viewSettings. - Adapt to regenerated views API types (
GenericView*) and add RTK Query endpoint overrides to preserve a stablepayloadmutation argument for create/update.
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/pages/VersionsProductsPage/context/VPViewsContext.tsx | Switch Versions view settings type import to frontend-owned settings types. |
| src/pages/ProjectsPage/hooks/useProjectSorting.ts | Repoint OverviewSettings typing to @shared/api/viewSettings. |
| src/pages/ProjectsPage/hooks/useProjectGrouping.ts | Repoint OverviewSettings typing to @shared/api/viewSettings. |
| src/pages/ProjectsPage/hooks/useProjectFilters.ts | Repoint OverviewSettings typing to @shared/api/viewSettings. |
| src/pages/ProjectsPage/hooks/useProjectColumnConfig.ts | Repoint OverviewSettings typing to @shared/api/viewSettings. |
| src/pages/ProjectOverviewPage/context/ProjectOverviewContext.tsx | Repoint OverviewSettings import to @shared/api/viewSettings. |
| src/pages/ProjectListsPage/context/ReviewCardsSettingsContext.tsx | Repoint ReviewsSettings import to @shared/api/viewSettings. |
| src/pages/ProjectListsPage/components/TableGridPlaylistSwitch/TableGridPlaylistSwitch.tsx | Repoint ReviewsSettings import to @shared/api/viewSettings. |
| src/pages/ProjectListsPage/components/ProjectListsDetailsPanels/ProjectListsDetailsPanels.tsx | Repoint ReviewsSettings import to @shared/api/viewSettings. |
| shared/src/util/columnConfigConverter.ts | Use frontend-owned OverviewSettings / ColumnItemModel types. |
| shared/src/containers/Views/utils/generateWorkingView.ts | Use GenericViewPostModel for working view payload generation. |
| shared/src/containers/Views/hooks/useViewsMutations.ts | Update mutation payload typing to use GenericViewPostModel. |
| shared/src/containers/Views/hooks/pages/useTaskProgressViewSettings.ts | Repoint view settings types to @shared/api/viewSettings. |
| shared/src/containers/Views/hooks/pages/useOverviewViewSettings.ts | Repoint view settings types to @shared/api/viewSettings. |
| shared/src/containers/Views/hooks/pages/useListsViewSettings.ts | Repoint view settings types to @shared/api/viewSettings. |
| shared/src/containers/Views/context/ViewsContext.tsx | Re-export ViewSettings from the new frontend-owned types module. |
| shared/src/api/viewSettings.ts | New: frontend-owned view settings / columns types. |
| shared/src/api/queries/views/updateViews.ts | Override RTK Query create/update mutations to keep FE mutation arg stable as payload. |
| shared/src/api/generated/views.ts | Regenerated views API types (GenericView*) and request body arg renaming (genericViewPostModel / genericViewPatchModel). |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
kalisp
left a comment
There was a problem hiding this comment.
Ran this with BE PR, switched between stored Views, re-saved some of them.
Didn't explode.
| // Codegen names the request body arg after its model (genericViewPostModel). | ||
| // Override the query so the whole FE keeps passing `payload`, regardless of | ||
| // how codegen names the arg on the next regen. | ||
| query: ({ viewType, projectName, payload }: CreateViewArg) => ({ |
There was a problem hiding this comment.
I'm not a fan of overriding the original query just so that it can use payload argument.
Can we please remove this and update the args to use genericViewPatchModel and convert all queries to use it.
OR get backend to change the arg name to something nicer (preferred).
Description of changes
Frontend now owns its view settings types instead of generating them from the REST schema, so adding a view setting no longer needs a backend change. Pairs with backend #974.
Technical details
shared/src/api/viewSettings.ts; all consumers repointed there.views.tsregenerated against Removed strongly typed View Settings ayon-backend#974 ->GenericView*.updateViews.tspins a stablepayloadcontract to keep saves working.Additional context
Pairs with ynput/ayon-backend#974